package com.joysuch.wwyt.report.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.joysuch.wwyt.bp.repository.BpJobDao;
import com.joysuch.wwyt.core.repository.BaseTypeGroupItemDao;
import com.joysuch.wwyt.report.bean.ReportRiskPointBean;
import com.joysuch.wwyt.report.bean.RiskControlListBean;
import com.joysuch.wwyt.report.mapper.ReportRiskPointMapper;
import com.joysuch.wwyt.report.service.ReportRiskPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;


@Service
public class ReportRiskPointServiceImpl implements ReportRiskPointService {
    @Autowired
    private ReportRiskPointMapper riskPointMapper;
    @Autowired
    private BpJobDao jobDao;
    @Autowired
    private BaseTypeGroupItemDao baseTypeGroupItemDao;

    @Override
    public Page<ReportRiskPointBean> getPointByDepartAndJobPaging(Long pageNo, Long pageSize, String pointType, String subType, Long departId, Long jobId) {
        //分页获取数据
        com.baomidou.mybatisplus.extension.plugins.pagination.Page<RiskControlListBean> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageNo, pageSize);
        Page<ReportRiskPointBean> riskPoints = riskPointMapper.getPointByDepartAndJob(page, pointType, subType, departId, jobId);
        riskPoints.getRecords().stream().forEach(each->{
            if (each.getDutyJobId() != null) {
                each.setDutyJobName(baseTypeGroupItemDao.getNameById(each.getDutyJobId()));
            }
        });
        return riskPoints;
    }
}

